#include "Vector2.h"

Vector2::Vector2()
{

}

Vector2::Vector2(const Vector2& v)
{
	*this = v;
}

float Vector2::x() const
{
	return e[0];
}

float Vector2::y() const
{
	return e[1];
}

float Vector2::operator[](int i) const
{
	if (i > 1) i = 1;
	if (i < 0) i = 0;
	return e[i];
}

float& Vector2::operator[](int i)
{
	if (i > 1) i = 1;
	if (i < 0) i = 0;
	return e[i];
}

void Vector2::setX(float _x)
{
	e[0] = _x;
}

void Vector2::setY(float _y)
{
	e[1] = _y;
}

istream& operator>>(istream &is, Vector2 &t)
{
	is >> t.e[0] >> t.e[1];
	return is;
}

ostream& operator<<(ostream &os, const Vector2 &t)
{
	os << t.e[0] << ' ' << t.e[1] << ' ';
	return os;
}